﻿Public Class CValueState3 : Inherits CStateBase

    ''' <summary>
    ''' 実行可能かを判断する
    ''' </summary>
    ''' <param name="task"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Overrides Function IsEnter(ByVal task As CTaskBase) As Boolean
        Debug.WriteLine("CVALUE_CHECKState.IsEnter")
        If CCommon.isInStr(task.ActionCd, "VALUE_CHECK") Then
            Return True
        Else
            Return False
        End If
    End Function

    ''' <summary>
    ''' 実行メソッド'今、照合しているデータのチェック
    ''' </summary>
    ''' <param name="task"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Overrides Function DoExecute(ByVal task As CTaskBase) As CStateBase
        Dim nextState As CStateBase
        Dim pdaTask As CPDATask3 = DirectCast(task, CPDATask3)
        Debug.WriteLine("CVALUE_CHECKState.DoExecute")
        Dim AppManager As CApplicationManager = CApplicationManager.GetInstance

        If task.ProcessText = "" Then
            pdaTask.WindowManager.SetMessage(CConst.CNS_MSG_053, CConst.COLOR_BLACK, CConst.COLOR_GREEN)
            '待つ状態
            task.ProcessText = task.ReadTextWait(-1)
        End If
        '絞るリストを選択するように
        Select Case task.ProcessText
            Case CConst.CNS_ENTER_OK

                Dim selectData As COrderRecord = pdaTask.WindowManager.GetCurrentLabelCheckRecord()

                If AppManager.m_AppSetting.SrvRecv Then
                    ''キューにたまらない---------------------




                Else
                    ''キューにたまる-------------------------
                    'CSVファイル作る
                    SyncLock pdaTask.m_SendLockObject
                        Try
                            Dim filePath As String = CApplicationManager.GetRealPath(CApplicationManager.SETTING_ACT_PATH, CApplicationManager.EnumSpecialFolder.PATH_MYDOCUMENT)
                            CBgControl.BgThread("cancel-" & System.Environment.TickCount.ToString(), "csv", filePath, CPersonal.CancelData(pdaTask), CConst.ORDER_DATA_UPLOAD)
                        Catch ex As Exception
                        End Try
                    End SyncLock
                End If

                '絞ったリストは削除---------------------->>START
                '絞るリストを取り消し
                Dim delRecord As ArrayList = New ArrayList()
                For i As Integer = 0 To pdaTask.WindowManager.GetLabelCancelCount - 1
                    Dim shpOrderData As COrderRecord = pdaTask.WindowManager.GetRecord(i, CBaseRecord.EnumRecordType.LabelCheck)
                    delRecord.Add(shpOrderData)
                Next
                For j As Integer = 0 To delRecord.Count - 1
                    pdaTask.WindowManager.DelRecord(delRecord(j), True)
                Next
                '絞ったリストは削除---------------------->>END

            Case CConst.CNS_CLR
                '絞ったリストを取り消し

                '絞ったリストは削除---------------------->>START
                '絞るリストを取り消し
                Dim delRecord As ArrayList = New ArrayList()
                For i As Integer = 0 To pdaTask.WindowManager.GetLabelCheckCount - 1
                    Dim shpOrderData As COrderRecord = pdaTask.WindowManager.GetRecord(i, CBaseRecord.EnumRecordType.LabelCheck)
                    delRecord.Add(shpOrderData)
                Next
                For j As Integer = 0 To delRecord.Count - 1
                    pdaTask.WindowManager.DelRecord(delRecord(j), True)
                Next
                '絞ったリストは削除---------------------->>END

        End Select


        task.ActionCd = "LABEL"
        task.ProcessText = ""
        nextState = GetNextState(task)
        Return nextState

    End Function

    ''' <summary>
    ''' 終了メソッド(未使用)
    ''' </summary>
    ''' <param name="task"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Overrides Function DoExit(ByVal task As CTaskBase) As Boolean
        Debug.WriteLine("CVALUE_CHECKState.DoExit")
        Return True
    End Function


End Class
